package de.realriot.ipsdroid.v1.beta;

import java.util.ArrayList;

import org.json.JSONException;
import org.json.JSONObject;

public class IPSListViewData {
	public ArrayList<JSONObject> catObjList = new ArrayList<JSONObject>();
	public ArrayList<JSONObject> insObjList = new ArrayList<JSONObject>();
	public ArrayList<JSONObject> varObjList = new ArrayList<JSONObject>();
	public ArrayList<JSONObject> scrObjList = new ArrayList<JSONObject>();

	public ArrayList<JSONObject> insChildObjList = new ArrayList<JSONObject>();
	public ArrayList<JSONObject> varList = new ArrayList<JSONObject>();
	public ArrayList<JSONObject> varProfileList = new ArrayList<JSONObject>();

	/**
     * Returns the variable-Object with the given ID.
     * 
     * @param id ID of the variable to return.
     * @return The wanted variable.
	 * @throws JSONException 
     */
	public JSONObject getVariable(String id) throws JSONException
	{
		for ( JSONObject ele : varList )
			if ( ele.getString("VariableID").equals(id) )
				return ele;
		return null;
	}

	/**
     * Returns the variableprofile-Object with the given name.
     * 
     * @param name Name of the variableProfile to return.
     * @return The wanted variableProfile.
	 * @throws JSONException 
     */
	public JSONObject getVarProfile(String name) throws JSONException
	{
		for ( JSONObject ele : varProfileList )
			if ( ele.getString("ProfileName").equals(name) )
				return ele;
		return null;
	}
}